package model;

import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Entity
@Table(name="interviews")
public class Interview extends BaseEntity{

	private static final long serialVersionUID = 1L;
	private List<Comment> comments;
	private List<User> interviewers;
	private Candidate candidate;
	
	private Date date;

	public Interview() {

	}

	public Interview(List<Comment> comments, List<User> interviewers, Candidate candidate,Date date) {
		super();
		this.comments = comments;
		this.interviewers = interviewers;
		this.candidate = candidate;
		this.date = date;
	}

	@ManyToMany(cascade={CascadeType.PERSIST})
	@JoinTable(name = "interviewcomment", joinColumns = { @JoinColumn(name = "id_interview") }, inverseJoinColumns = { @JoinColumn(name = "id_comment") })
	public List<Comment> getComments() {
		return comments;
	}

	public void setComments(List<Comment> comments) {
		this.comments = comments;
	}

	@ManyToMany
	@JoinTable(name = "userinterview", joinColumns = { @JoinColumn(name = "id_interview") }, inverseJoinColumns = { @JoinColumn(name = "id_user") })
	public List<User> getInterviewers() {
		return interviewers;
	}

	public void setInterviewers(List<User> interviewers) {
		this.interviewers = interviewers;
	}
	
	@ManyToOne 
	@JoinColumn (name="id_candidate")
	public Candidate getCandidate() {
		return candidate;
	}

	public void setCandidate(Candidate candidate) {
		this.candidate = candidate;
	}

	@Column(name = "date")
	@Temporal(TemporalType.DATE)
	public Date getDate() {
		return date;
	}

	public void setDate(Date date) {
		this.date = date;
	}

}
